//
//  QBVoteCell.m
//  QiuBai
//
//  Created by yaohongchao on 5/1/16.
//  Copyright © 2016 yaohongchao. All rights reserved.
//

#import "QBVoteView.h"


@interface QBVoteView()
@property(nonatomic,weak)UILabel *lblReadInfo;
@end

@implementation QBVoteView

-(instancetype)init{
    self = [super init];
    if(self){
        [self setui];
    }
    return self;
}

-(void)setui{
    WS(weakSelf);
    UILabel *lblReadInfo = [[UILabel alloc]init];
    lblReadInfo.textColor = [UIColor colorWithHexString:@"#9c9ca1"];
    lblReadInfo.font = [UIFont systemFontOfSize:12];
    [self addSubview:lblReadInfo];
    self.lblReadInfo = lblReadInfo;
    [lblReadInfo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf).offset(kMargin);
        make.right.equalTo(weakSelf).offset(-kMargin);
        make.top.equalTo(weakSelf).offset(kMargin);
        make.height.mas_equalTo(20);
    }];
    
    UIButton *btnLike = [[UIButton alloc]init];
    [btnLike setImage:[UIImage imageNamed:@"qb_btn_articlelike_nor"] forState:UIControlStateNormal];
    [self addSubview:btnLike];
    [btnLike mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lblReadInfo.mas_bottom).offset(5);
        make.width.height.mas_equalTo(40);
        make.left.equalTo(weakSelf).offset(20);
    }];
    
    UIButton *btnAgaist = [[UIButton alloc]init];
    [btnAgaist setImage:[UIImage imageNamed:@"qb_btn_agaist_nor"] forState:UIControlStateNormal];
    [self addSubview:btnAgaist];
    [btnAgaist mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btnLike.mas_right).offset(35);
        make.centerY.equalTo(btnLike.mas_centerY);
        make.width.height.mas_equalTo(40);
    }];
    
    UIButton *btnComment = [[UIButton alloc]init];
    [btnComment setImage:[UIImage imageNamed:@"qb_btn_comment"] forState:UIControlStateNormal];
    [self addSubview:btnComment];
    [btnComment mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btnAgaist.mas_right).offset(35);
        make.centerY.equalTo(btnAgaist.mas_centerY);
        make.width.height.mas_equalTo(40);
    }];
    
    UIButton *btnShare = [[UIButton alloc]init];
    [btnShare setImage:[UIImage imageNamed:@"qb_btn_share"] forState:UIControlStateNormal];
    [self addSubview:btnShare];
    [btnShare mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf).offset(-kMargin);
        make.centerY.equalTo(btnComment.mas_centerY);
        make.width.height.mas_equalTo(40);
    }];
}

-(void)setVote:(Vote *)vote{
    _vote = vote;
    self.lblReadInfo.text = [NSString stringWithFormat:@"好笑%ld   ·   评论%ld",(long)vote.up,(long)vote.comment];
}

@end
